#!/bin/sh

# a basic script for maximum pretty

# X-based modes
if [[ -n "$DISPLAY" && -x /usr/bin/aterm ]]; then
  exec aterm -fn mtx -e cmatrix -abox
  exit
fi
if [[ -n "$DISPLAY" && -x /usr/bin/xterm ]]; then
  exec xterm -fn mtx -en iso1252 -e cmatrix -abx
  exit
fi

# safe mode
if [[ "$TERM" != "linux" ]]; then
    exec cmatrix -abo
    exit
fi

# custom font mode
setfont matrix
cmatrix -abol

# and put the font back, if possible
default_font=""
if [[ -f /etc/vconsole.conf ]]; then
    while IFS='=' read -r k v; do
        if [ "${k# *}" = FONT ]; then
             default_font="$v"
        fi
    done < /etc/vconsole.conf
fi
if [[ -n "$default_font" ]]; then
    setfont "$default_font"
else
    echo "No font in vconsole.conf, could not restore."
fi

